<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>data必须是一个函数</title>
    <script src="vue.js"></script>  
    <link rel="stylesheet" href="global.css" />

  </head>
  <body>
    <div id="app">
      <app-component></app-component>
      <app-component></app-component>
      <app-component></app-component>
    </div>
    <script>
      Vue.component("app-component", {
        template: '<button v-on:click="counter += 1">{{ counter }}</button>',
        data: function () {
          return { counter: 0 };
        },
      });
      // 创建根实例
      new Vue({
        el: "#app",
      });
    </script>
  </body>
</html>
